package com.huatao.practice.server.controller;

import com.alibaba.fastjson.JSON;
import com.huatao.auth.entity.Result;
import com.huatao.practice.api.vo.SpecialPracticeVo;
import com.huatao.practice.server.service.PracticeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/practice/set")
@Slf4j
public class PracticeSetController {

    @Resource
    private PracticeService practiceService;

    @PostMapping("getSpecialPracticeContent")
    public Result<List<SpecialPracticeVo>> getSpecialPracticeContent() {
        try {
            List<SpecialPracticeVo> result = practiceService.getSpecialPracticeContent();
            if (log.isInfoEnabled()) {
                log.info("getSpecialPracticeContent.result: {}", JSON.toJSONString(result));
            }
            return Result.ok(result);
        } catch (Exception e) {
            log.error("getSpecialPracticeContent.error: {}", e.getMessage(), e);
            return Result.fail("专项内容获取失败");
        }
    }
}
